// import axios from 'axios'

const createGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/ProjectGroupOfMe/createProjectGroup', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const getGroupList = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/ProjectGroupOfMe/projectGroupList', {params}).then(res => {
            resolve(res.data.data)
        }).catch(err => {
            reject(err)
        })
    })
}

const getGroupDetail = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/ProjectGroupOfMe/projectGroupDetail', {params}).then(res => {
            resolve(res.data.data)
        }).catch(err => {
            reject(err)
        })
    })
}

const editGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/ProjectGroupOfMe/saveProjectGroup', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const disbandGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/ProjectGroupOfMe/disbandGroup', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const addProjectIntoGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/ProjectGroupOfMe/addOnes', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const removeProjectOutOfGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/ProjectGroupOfMe/removeOnes', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const getJoinGroupList = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/MyJoinProjectGroup/MyJoinProjectGroup', {params}).then(res => {
            resolve(res.data.data)
        }).catch(err => {
            reject(err)
        })
    })
}

const exitGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/MyJoinProjectGroup/exitGroup', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const getGroupApplyList = async () => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/ProjectGroupOfMe/applyJoinList').then(res => {
            resolve(res.data.data);
        }).catch(err => {
            reject(err);
        });
    });
}

const agreeJoinGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/ProjectGroupOfMe/agreeJoin', params).then(res => {
            resolve(res);
        }).catch(err => {
            reject(err);
        });
    });
}

const refuseAnApplication = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/ProjectGroupOfMe/refuseApplyJoin', params).then(res => {
            resolve(res);
        }).catch(err => {
            reject(err);
        })
    })
}

const getGroupInviteList = async () => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/MyJoinProjectGroup/inviteJoinList').then(res => {
            resolve(res.data.data);
        });
    });
}

const joinGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/MyJoinProjectGroup/joinGroup', params).then(res => {
            resolve(res);
        }).catch(err => {
            reject(err);
        });
    })
}

const refuseJoinGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/MyJoinProjectGroup/refuseApplyJoin', params).then(res => {
            resolve(res);
        }).catch(err => {
            reject(err);
        });
    });
}

const applyJoinGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/MyJoinProjectGroup/applyJoin', params).then(res => {
            resolve(res);
        }).catch(err => {
            reject(err);
        });
    })
}

const getMyJoinGroupInfo = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/MyJoinProjectGroup/myJoinGroupInfo', {params}).then(res => {
            resolve(res.data.data);
        }).catch(err => {
            reject(err);
        });
    });
}

const editMyJoinGroup = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/MyJoinProjectGroup/editMyJoinGroup', params).then(res => {
            resolve(res);
        }).catch(err => {
            reject(err);
        });
    });
}

export default {
    createGroup,
    getGroupList,
    getGroupDetail,
    editGroup,
    disbandGroup,
    addProjectIntoGroup,
    removeProjectOutOfGroup,
    getJoinGroupList,
    exitGroup,
    getGroupApplyList,
    agreeJoinGroup,
    refuseAnApplication,
    getGroupInviteList,
    joinGroup,
    refuseJoinGroup,
    applyJoinGroup,
    getMyJoinGroupInfo,
    editMyJoinGroup
}
